package com.zzq.base.awesome;

import com.zzq.base.awesome.controller.IgnoreUrlList;
import com.zzq.base.awesome.entity.CommonData;
import com.zzq.base.awesome.entity.SingleObject;
import com.zzq.base.awesome.utils.SystemUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.event.ApplicationEnvironmentPreparedEvent;
import org.springframework.boot.context.event.ApplicationPreparedEvent;
import org.springframework.boot.context.event.ApplicationStartedEvent;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.context.ApplicationEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ApplicationContextEvent;

import java.io.File;

import static com.zzq.base.awesome.entity.CommonData.APILOCATION;
import static com.zzq.base.awesome.entity.CommonData.ROOTPACKAGE;
import static com.zzq.base.awesome.utils.SystemUtils.isWindows;

@SpringBootApplication
@MapperScan(value = {ROOTPACKAGE + ".*.mapper",APILOCATION + ".*.mapper"})
@ServletComponentScan
@Slf4j
public class AwesomeApplication implements ApplicationListener<ApplicationContextEvent> {
    public static void main(String[] args) {
        SpringApplication.run(AwesomeApplication.class, args);
    }

    @Override
    public void onApplicationEvent(ApplicationContextEvent event) {
        log.info("添加忽略路由");
        IgnoreUrlList.init();
        log.info("设置系统文件路径");
        SystemUtils.initFile(log);
        log.info("see http://localhost/static/a/video.html");
    }
}
